﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Avatar.Model;
using Avatar.Common;
using System.Text;

public partial class UserControl_Search : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PanelCityList.Visible = false;
            PanelCity.Visible = true;
        }
    }
    protected void ImgButton_search_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            if (string.IsNullOrEmpty(txt_CityID.Value)) throw new Exception("请选择地点");
            if (string.IsNullOrEmpty(txt_KeyWord.Text))throw new Exception("搜索关键字不能为空");

            string _condition = string.Empty;

            _condition += "type=" + ddl_Type.SelectedValue;
            _condition += "&location=" + txt_CityID.Value;
            _condition += "&keyword=" + txt_KeyWord.Text;

            Response.Redirect("./JobSearch.aspx?" + Server.UrlEncode(_condition));
        }
        catch (Exception _e)
        {
            Helper.ShowMassage(_e.Message);
        }
    }
    protected void btn_CitySelect_Click(object sender, EventArgs e)
    {
        PanelCityList.Visible = false;
        PanelCity.Visible = true;

        var _city = AreaManager.GetArea(Location1.City);
        if (_city != null)
        {
            txt_CityID.Value = _city.ID.ToString();
            txt_CityName.Text = _city.Name;
        }

    }
    protected void btn_OpenPanel_Click(object sender, EventArgs e)
    {
        PanelCityList.Visible = true;
        PanelCity.Visible = false;
    }
}
